package com.xcity.game.turntable;

import java.util.List;

import com.xcity.game.item.ItemInfo;
import com.xcity.util.ArrayList;

import naga.x.game.template.Template;
import naga.x.game.template.TemplateException;
import naga.x.game.template.annotation.Excel;

/**
 * 奇遇v1
 * @see 
 * @author yang.li
 *
 */
@Deprecated
@Excel(value = "turntable.xlsx", sheet = 0)
public class TurnTableTemplate extends Template {

	/** 占用格子数 */
	protected int count;

	/** 物品1id */
	protected int[] items;
	
	protected List<ItemInfo> itemList;

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int[] getItems() {
		return items;
	}

	public void setItems(int[] items) {
		this.items = items;
	}
	
	public List<ItemInfo> getItemList() {
		return itemList;
	}
	
	public ItemInfo getItem(int index) {
		return itemList.get(index);
	}

	@Override
	public void validate() throws TemplateException {
		int len = items.length;
		ItemInfo[] ref = new ItemInfo[len >> 1];
		for (int i = 0, pos = 0; i < len; i += 2) {
			ref[pos++] = new ItemInfo(items[i], items[i + 1]);
		}
		itemList = new ArrayList<ItemInfo>(ref);
		items = null; // free
	}
}
